<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="Comment.Comment" %>
<%@ page import="Page.Page"   %>
<%@ page import="java.util.*"  %>
<%@ page import="Comment.CommentDeal"%>
<%
   //从数据库中去出结果集
   int currentRecord = 0;
   String sql="";
   int k=0;
   int k1=0;
   Page pager=new Page();
   CommentDeal db=new CommentDeal();
   String SellerID=request.getParameter("SellerID");
   ArrayList<Comment> result =db.ShowComment(SellerID); 
   pager.setPageSize(6);
   pager.setTotalRecord(result.size());
   pager.setTotalPage(result.size(),pager.getPageSize());
   //计算并设置分页的参数
   if(request.getParameter("currentRecord")!=null)
   {   
       currentRecord = Integer.parseInt(request.getParameter("currentRecord"));
       pager.setCurrentRecord(currentRecord);
       pager.setCurrentPage(currentRecord,pager.getPageSize());
   }
   //从结果集中取出当前页面要显示的子集
   List<Comment> subResult = null;
   if(currentRecord == 0)
   {
       if(currentRecord+pager.getPageSize()<=result.size())
       {
            subResult = result.subList(0,pager.getPageSize());
       	
       }
       else
       {
       	   	subResult = result.subList(0,result.size());
       }
   
   }
   else if(pager.getCurrentRecord()+pager.getPageSize()<result.size())
       subResult = result.subList(pager.getCurrentRecord(),pager.getCurrentRecord

()+pager.getPageSize());
   else
       subResult = result.subList(pager.getCurrentRecord(),result.size());
 %>
<html>
  <head>
  </head>

  <body>
  <font size="2"><strong>管理员信息如下：</strong><br>
   </font>
   <table width="900" border="1" height="82">
   		<tr>
   			<td>评价编号</td>
   			<td>卖家编号</td>
   			<td>买家编号</td>
   			<td>评论时间</td>
   			<td>评分</td>
   		</tr>
   		<%
   			 if(subResult.isEmpty()==false)
		       {
		             for(int i=0;i<subResult.size();i++)
		             {
		            	 Comment Comment = subResult.get(i);
		            	 CommentDeal d=new CommentDeal();
						 out.print("<tr>");
		                 out.print("<td>"+Comment.getCommentID()+"</td>");
		                 out.print("<td>"+Comment.getSellerID()+"</td>");
		                 out.print("<td>"+Comment.getBuyerID()+"</td>");
		                 out.print("<td>"+Comment.getCommentTime()+"</td>");
		                 out.print("<td>"+Comment.getComID()+"</td>");
		             }
		        }
   		 %>	
   	</table>
   	<table><tr><td><a href="javascript:history.go(-1);">返回</a></td></tr></table>
   	<span><font size="2">总<%=pager.getTotalRecord()%>条记录|总<%=pager.getTotalPage()%>页|当

前<%=pager.getCurrentPage()+1%>页|每页<%=pager.getPageSize()%>条|
<% 
    //如果已经到了首页就去掉前一页的链接
    if(pager.getCurrentRecord()-pager.getPageSize()<0)
        out.println("首页|");
    else
    //上一页就是把当前记录位置减去一页显示记录的条数
        out.print("<a href='CommentDetailed.jsp?currentRecord="+(pager.getCurrentRecord()-

pager.getPageSize())+"&pageSize="+pager.getPageSize()+"&SellerID="+SellerID+"'>上一页</a>|");
    //如果到了尾页就去掉下一页的链接
    if(pager.getCurrentRecord()+pager.getPageSize()>=pager.getTotalRecord())
        out.println("尾页");
    else
    //下一页就是把当前记录位置加上一页显示记录的条数
        out.print("<a href='CommentDetailed.jsp?currentRecord="+(pager.getCurrentRecord

()+pager.getPageSize())+"&pageSize="+pager.getPageSize()+"&SellerID="+SellerID+"'>下一页</a>|"); 
%>
</font></span>
  </body>
</html>
